package com.city.java.report_videos.controller;

import com.city.java.report_videos.pojo.entity.ReportVideos;
import com.city.java.report_videos.service.ReportVideoService;
import com.city.java.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 举报视频控制器
 * RestController注解: 组合注解，相当于@Controller + @ResponseBody
 * Api注解: Knife4j文档中模块的显示名称
 * RequestMapping注解: 设置统一的请求路径前缀
 */
@Slf4j
@Api(tags = "06.举报视频模块")
@RestController
@RequestMapping("/api/report-videos")
public class ReportVideoController {

    @Autowired
    private ReportVideoService reportVideoService;

    /**
     * 添加举报视频
     * PostMapping注解: 处理POST请求
     * ApiOperation注解: Knife4j文档中接口的显示名称
     */
    @PostMapping("add")
    @ApiOperation(value = "添加举报视频", notes = "添加新举报视频信息")
    public JsonResult addReportVideo(
            @ApiParam(value = "举报视频信息", required = true)
            @RequestBody ReportVideos reportVideo) {
        log.info("接收到添加举报视频请求: {}", reportVideo);
        return reportVideoService.addReportVideo(reportVideo);
    }

    /**
     * 根据举报视频ID查询举报视频
     * GetMapping注解: 处理GET请求
     * PathVariable注解: 获取路径中的参数
     */
    @GetMapping("/select/video/{reportVideoId}")  // 修改路径以区分
    @ApiOperation(value = "根据ID查询举报视频", notes = "根据举报视频ID查询举报视频详细信息")
    public JsonResult getReportVideoById(
            @ApiParam(value = "举报视频ID", required = true, example = "1")
            @PathVariable Long reportVideoId) {
        log.info("接收到根据ID查询举报视频请求: ID={}", reportVideoId);
        return reportVideoService.getReportVideoById(reportVideoId);
    }

    /**
     * 根据举报ID查询举报视频列表
     * RequestParam注解: 获取请求参数
     */
    @GetMapping("/select/report/{reportId}")  // 修改路径以区分
    @ApiOperation(value = "根据举报ID查询举报视频", notes = "根据举报ID查询举报视频列表")
    public JsonResult getReportVideosByReportId(
            @ApiParam(value = "举报ID", required = true, example = "1")
            @PathVariable Long reportId) {
        log.info("接收到根据举报ID查询举报视频请求: reportId={}", reportId);
        return reportVideoService.getReportVideosByReportId(reportId);
    }

    /**
     * 查询所有举报视频列表
     */
    @GetMapping("/quarry")
    @ApiOperation(value = "查询所有举报视频", notes = "查询所有举报视频列表")
    public JsonResult getAllReportVideos() {
        log.info("接收到查询所有举报视频请求");
        return reportVideoService.getAllReportVideos();
    }

    /**
     * 根据举报视频ID删除举报视频
     * DeleteMapping注解: 处理DELETE请求
     */
    @DeleteMapping("/{reportVideoId}")
    @ApiOperation(value = "根据ID删除举报视频", notes = "根据举报视频ID删除举报视频")
    public JsonResult deleteReportVideoById(
            @ApiParam(value = "举报视频ID", required = true, example = "1")
            @PathVariable Long reportVideoId) {
        log.info("接收到根据ID删除举报视频请求: ID={}", reportVideoId);
        return reportVideoService.deleteReportVideoById(reportVideoId);
    }

    /**
     * 根据举报ID删除举报视频
     */
    @DeleteMapping("/report/{reportId}")
    @ApiOperation(value = "根据举报ID删除举报视频", notes = "根据举报ID删除举报视频")
    public JsonResult deleteReportVideosByReportId(
            @ApiParam(value = "举报ID", required = true, example = "1")
            @PathVariable Long reportId) {
        log.info("接收到根据举报ID删除举报视频请求: reportId={}", reportId);
        return reportVideoService.deleteReportVideosByReportId(reportId);
    }

    /**
     * 更新举报视频信息
     * PutMapping注解: 处理PUT请求
     */
    @PutMapping
    @ApiOperation(value = "更新举报视频信息", notes = "更新举报视频详细信息")
    public JsonResult updateReportVideo(
            @ApiParam(value = "举报视频信息", required = true)
            @RequestBody ReportVideos reportVideo) {
        log.info("接收到更新举报视频信息请求: {}", reportVideo);
        return reportVideoService.updateReportVideo(reportVideo);
    }
}
